package me.aip.mov.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import me.aip.mov.annotation.GlobalResult;
import me.aip.mov.annotation.PassToken;
import me.aip.mov.controller.vo.LabelVod;
import me.aip.mov.entity.Vod;
import me.aip.mov.service.IVodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author aip9105
 * @since 2022-01-27
 */
@RestController
@GlobalResult
@PassToken
@RequestMapping("/vod")
public class VodController {
    @Autowired
    IVodService iVodService;

    @GetMapping("detail")
    public Vod findVodDetail(Integer vodId) {
        return iVodService.getById(vodId);
    }

    @GetMapping("page")
    public Page<Vod> findVodPage(Page page,Vod vod) {
        return iVodService.findVodPage(page,vod);
    }

    @GetMapping("carousel")
    @Cacheable(cacheNames="findCarousel#900",key="#typePid+'-'+#t")
    public List<Vod> findCarousel(Integer typePid,String t) {
        return iVodService.findCarousel(typePid);
    }
    @GetMapping("search")
    public Page<Vod> searchVod(Page page,String keyword) {
        return iVodService.searchVod(page,keyword);
    }

    @GetMapping("guess")
    @Cacheable(cacheNames = "guessVod#900", key = "'guess-'+#keyword+'-'+#t")
    public List<Vod> guessVod(String keyword,String t) {
        return iVodService.guessVod(keyword);
    }

    @GetMapping("recommend")
    @Cacheable(cacheNames = "recommendVod#900", key = "#typePid+'-'+#typeId+'-'+#t")
    public List<Vod> recommendVod(String keyword,Integer typePid,Integer typeId,String t) {
        return iVodService.recommendVod(keyword,typePid,typeId);
    }

    @GetMapping("labelVodList")
    @Cacheable(cacheNames="labelVodList#900",key="#typePid+'-'+#t")
    public List<LabelVod> labelVodList(Integer typePid,String t) {
        return iVodService.labelVodList(typePid);
    }


    @GetMapping("hotList")
    @Cacheable(cacheNames="hotList#900")
    public List<Vod> hotList() {
        return iVodService.hotList();
    }
}
